import os
import json
from .terLog import terLog
class TTerSettings(json.JSONEncoder):
    terCode = ""
    terName = ""
    terDesc = ""
    def __init__(self):
        pass
    def dict(self):
        return{
            "terCode": self.terCode ,
            "terName": self.terName ,
            "terDesc": self.terDesc 
        }
    def loadFromLocal(self , settingFile):
        try:
            if  os.path.exists(settingFile) :
                    with open(settingFile , "r+", encoding="utf-8") as file:
                        try:
                            content = file.read()
                            jsonObj = json.loads(content)
                            self.terCode = jsonObj['terCode']
                            self.terName = jsonObj['terName']
                            self.terDesc = jsonObj['terDesc']
                        except Exception as eer:
                            terLog('e' , eer)
        except Exception as er:
            terLog('e' , er)